<template>
  <el-dialog
    v-model="dialogVisible"
    title="成本核算"
    width="1000"
    class="qc-custom-dialog"
  >
    <el-scrollbar class="dialog-scroll-wrap">
      <Table
        ref="tableDialogRef"
        :columns="data.columns"
        :params="{ id: data.id }"
        :list="data.list"
        :isPagination="false"
      ></Table>
    </el-scrollbar>
  </el-dialog>
</template>

<script lang="ts" setup name="dialog-costing">
import Table from '@/components/table/index.vue';
import { costingActivity } from '@/service/apis/market';

const tableDialogRef = ref();
let dialogVisible = ref(false);

const data = reactive({
  id: '',
  list: [] as any,
  columns: [
    {
      prop: 'orgName',
      label: '承担方',
    },
    {
      prop: 'dutyRatio',
      label: '承担比例',
      template: (row: any, index: number) => {
        return `${row.dutyRatio}%`;
      },
    },
    {
      prop: 'estimatedHighestCost',
      label: '预计最高成本（元）',
    },
    {
      prop: 'estimatedCost',
      label: '预计产生成本（元）',
    },
    {
      prop: 'actualCost',
      label: '实际产生成本（元）',
    },
  ],
});

const show = (row: any) => {
  data.list = [];
  costingActivity(row.id).then((res: any) => {
    if (res) {
      data.list = res;
    }
  });
  dialogVisible.value = true;
};

defineExpose({
  show,
});
</script>